#include <bits/stdc++.h>

using namespace std;

int solve(int a, int b) {
    if(a <= b) {
        return b - a;
    } else {
        if(a & 1) {
            return solve(a + 1, b) + 1;
        } else {
            return solve(a / 2, b) + 1;
        }
    }
}

int main(int argc, char const *argv[]) {
    int a, b, cnt = 0;
    cin >> a >> b;
    cout << solve(a, b) << endl;
    return 0;
}
